﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TAdMagazine.aspx.cs" Inherits="Admagazine_TAdMagazine" %>
<%@ Register Assembly="GMDatePicker" Namespace="GrayMatterSoft" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery0905.js" type="text/javascript"></script>
    <script src="../js/jqModal.js" type="text/javascript"></script>  
    <script language="JScript" src="../js/myCheck.js"></script>
    <link href="../css/pagebox.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript">  
    function NotCharacter(str,name)
    {
        var vstr =/^[A-Za-z0-9]+$/;
        if(!vstr.test(str)){
        alert(name+"必须是字母或数字!");
        return false;}
    }
    
    function chk() 
	{
	    $('#txtMagCode').val($.trim( $('#txtMagCode').val()));
	    $('#txtMagName').val($.trim( $('#txtMagName').val()));
	    $('#txtMagName2').val($.trim( $('#txtMagName2').val()));
	    $('#txtNotice').val($.trim( $('#txtNotice').val()));
	   

		if(CheckText(form1.txtMagCode,"编码",20)==false) return false;
		if(NotCharacter(form1.txtMagCode.value,"编码")==false) return false;
		if(CheckText(form1.txtMagName,"全称",30)==false) return false;
		if(CheckText(form1.txtMagName2,"简称",20)==false) return false;
		if(CheckText(form1.txtNotice,"描述",200)==false) return false;

		return true;
	}
   
    
    $().ready(function() {
        $('#divInput').jqm({modal: true,trigger: '#btnAdd'});
        
    });
    var opration="";
   
    function showdiv()
    {
        $('#divInput').jqmShow(); 
    }
    function inputbind(strid)
    {
        gettype(strid);
        $('#tdtitle').text("修改");
        var urlstring="tadmagazine.aspx";
            $.ajax({
            url:urlstring,
            type:'post',
            dataType:'html',
            data:'&opration=bind&id='+ strid ,
            beforeSend:function()
            {
               
            },
            error:function()
            {
               
            },
            success: function(msg)
            {
                var val=msg.split(',');
                $('#txtMagCode').val(val[0]);
                $('#txtMagName').val(val[1]);
                $('#txtMagName2').val(val[2]);
                $('#txtNotice').val(val[3]);
                $("#seltype > option[value=" + val[4] + "]").attr("selected","true");
                $('#gmdpCreateDate_dateLabel').text(val[5])
                $('#divInput').jqmShow(); 
                opration='edit';
                $('#txtMagCode').attr('disabled',true);
            }
            });
    }
    
    function save()
    {
        
        if(!chk())return;
         if(opration=="")
            opration="save";
            var urlstring="tadmagazine.aspx";
            $.ajax({
            url:urlstring,
            type:'post',
            dataType:'html',
            data:'&opration='+opration+'&code='+escape($('#txtMagCode').val()) + "&name=" + escape($('#txtMagName').val()) +"&name2="+ escape($('#txtMagName2').val()) + "&type=" + form1.seltype.value + "&createtime=" +$('#gmdpCreateDate_dateLabel').text() + "&notice="+escape($('#txtNotice').val()) ,
            beforeSend:function()
            {
            },
            error:function()
            {
               
            },
            success: function(msg)
            {
                if(msg=="")
                {
                    
                    $('#divInput').jqmHide(); 
                    opration='';
                    $('#txtMagCode').attr('disabled',false);
                    location.href=location.href;
                }
                else
                {
                    alert(msg);
                }
            }
            });
    }
    
   function del(strid)
    {
        var urlstring="tadmagazine.aspx";
            $.ajax({
            url:urlstring,
            type:'post',
            dataType:'html',
            data:'&opration=del&id='+ strid ,
            beforeSend:function()
            {
               
            },
            error:function()
            {
               
            },
            success: function(msg)
            {
                opration='edit';
                $('#txtTypeID').attr('disabled',true);
                location.href=location.href;
            }
            });
    }
    function clearin()
    {
        
        $(".in").val('');
        
        $('#tdtitle').text("添加");
    }
    function gettype()
    {
        var urlstring="tadmagazine.aspx";
        $.ajax({
        url:urlstring,
        type:'post',
        dataType:'html',
        data:'&opration=seltype',
        beforeSend:function()
        {
            
        },
        error:function()
        {
           
        },
        success: function(msg)
        {
            $("#seltype > option").remove();
            var types=msg.split(',');
            for(i=0;i<types.length;i++)
            {
                var type=types[i].split("|");
                $("#seltype").append('<option value='+ type[0]+'>'+type[1]+'</option>');
            }
            $("#seltype > option:first-child").attr("selected","true");
        }
        });
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="divInput" class="jqmWindow" style="display:none; left: 60%; width: 350px; top: 14%;">
         <table width='100%' style ="background-color:#0075b0">
            <tr>
                <td align="left" id='tdtitle' style="font-size:12px;color:White"></td><td align="right" ><asp:ImageButton ID="btnPanel2Cancel" runat="server" ImageUrl="~/adsetup/images/close.png" CausesValidation='false' OnClick="btnPanel2Cancel_Click" /></td>
            </tr>
        </table>
        <br />
        <table width='100%'>
            <tr>
                <td align="right" >编码:</td>
                <td><asp:TextBox CssClass='in' ID='txtMagCode' Text='101' runat="server" ></asp:TextBox></td>
            </tr>
            <tr>
                <td align="right">
                    全称:</td>
                <td><asp:TextBox CssClass='in' ID='txtMagName' runat="server"  ></asp:TextBox></td>
            </tr>
            <tr>
                <td align="right">简称:</td>
                <td><asp:TextBox CssClass='in' ID='txtMagName2' runat="server"  ></asp:TextBox></td>
            </tr>
            <tr>
                <td align="right">所属类别:</td>
                <td>
                    <select id='seltype'  ></select>
                </td>
            </tr>
            <tr>
                <td align="right">创刊时间:</td>
                <td>
                    <cc1:gmdatepicker id="gmdpCreateDate" runat="server" DisplayMode="Label" ShowNoneButton="False"></cc1:gmdatepicker>
                </td>
            </tr>
            <tr>
                <td align="right">描述:</td>
                <td><asp:TextBox CssClass='in' ID='txtNotice' runat="server" TextMode="MultiLine"  ></asp:TextBox></td>
            </tr>
            <tr>
                <td colspan='2' align="center">
                    <input type="button" id='btnSave1' value='保存' onclick ="save()" style="color: white; width:50px; height: 20px; background-color: #296cb3" />
                </td>
            </tr>
        </table><br /></div>
    
    <div>
       <table cellSpacing="0" cellPadding="0" border="0" align="center">
		    <tr>
		        <td style="background-color:White;padding-right: 10px; padding-left: 10px; padding-bottom: 10px; padding-top: 10px;">
		            <table cellSpacing="0" cellPadding="0" width="600" align="center" border="0" style="background-color:White;">
		                <tr>
		                    <td style="BORDER-RIGHT: #90b0de 1px solid; BORDER-TOP: #90b0de 1px solid; BORDER-LEFT: #90b0de 1px solid; BORDER-BOTTOM: #90b0de 1px solid; height: 213px;">
		                        <table width="100%" cellSpacing="0" cellPadding="0" align="center" border="0">
		                            <tr height="30">
		                                <td style="border-bottom: #90b0de 1px solid; background-color: #ecf5ff; font-weight: bold; color: #004499; border-top-width: 1px; border-left-width: 1px; border-left-color: #90b0de; border-top-color: #90b0de; border-right-width: 1px; border-right-color: #90b0de;">&nbsp;&nbsp;&nbsp;??????</td>
		                            </tr>
		                        </table>
		                        
		                        
                                <div id="Div1" style="margin-top:10px;margin-bottom:0px;margin-left:10px;">
		                            <table cellSpacing="0" cellPadding="0" width="100%" border="0">
			                            <tr>
				                            <td height="24">
                                                <asp:button Width='50' id="btnAdd" runat="server" OnClientClick='clearin();gettype();' Height='20' Text="添加"  CausesValidation="false" BackColor="#296CB3" ForeColor="White" ></asp:button></td>
			                            </tr>
		                            </table>
                                </div>
                                <div id="mnglist" style="margin-top:10px;margin-bottom:10px;margin-left:10px;margin-right:10px;">
                                    <asp:GridView Font-Size='13px' ID="dlTable" runat="server" AlternatingRowStyle-BackColor ='#ECF5FF'  SelectedRowStyle-BackColor="#cee5fd" Width="100%" AutoGenerateColumns="False" OnRowCommand="dlTable_RowCommand" GridLines="None"  >
                                        <Columns>
                                            <asp:TemplateField HeaderText ="编码">
                                                <ItemTemplate>
                                                    <a href='javascript:void(0)' style= "color:#004499"   onclick ='javascript:opration="edit";inputbind("<%#Eval("magcode") %>")'><%#Eval("magcode") %></a>
                                                </ItemTemplate>
                                                <HeaderStyle HorizontalAlign="center" Width='80' />
                                                <ItemStyle HorizontalAlign="Center" Width='80' />
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="magname" HeaderText="全称" >
                                                <ItemStyle HorizontalAlign="Center" Width='80' />
                                                <HeaderStyle HorizontalAlign="center" Width='80' />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="magname2" HeaderText="简称" >
                                                <ItemStyle HorizontalAlign="Center" Width='80' />
                                                <HeaderStyle HorizontalAlign="center" Width='80' />
                                            </asp:BoundField>
                                              <asp:BoundField DataField="infoname" HeaderText="所属类别" >
                                                <ItemStyle HorizontalAlign="Center" Width='80' />
                                                <HeaderStyle HorizontalAlign="center" Width='80' />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="notice" HeaderText="备注" Visible='false' >
                                                <ItemStyle HorizontalAlign="Center" />
                                                <HeaderStyle HorizontalAlign="center" />
                                            </asp:BoundField>
                                            <asp:TemplateField HeaderText ="下一级">
                                                <ItemTemplate>
                                                    <a href='tadmagazineissue.aspx?typeid=<%#Eval("magcode") %>'>下一级</a>
                                                </ItemTemplate>
                                                <ItemStyle HorizontalAlign="Center" Width='80' />
                                                <HeaderStyle HorizontalAlign="center" Width='80' />
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="删除">
                                                <ItemTemplate>
                                                    <span style= "color:#004499"  ><asp:linkbutton  id="lbDelete" runat="server" CommandName="Del" CommandArgument='<%#Eval("magcode") %>' Font-Strikeout="true"><img border="0" src="./images/del.gif" alt="删除" onClick="javascript:{return confirm('删除操作不可恢复，确认吗？');}"></asp:linkbutton></span>
                                                </ItemTemplate>
                                                <ItemStyle HorizontalAlign="Center" Width='80' />
                                                <HeaderStyle HorizontalAlign="center" Width='80' />
                                            </asp:TemplateField>
                                        </Columns>
                                        <SelectedRowStyle BackColor="#CEE5FD" />
                                        <AlternatingRowStyle BackColor="#ECF5FF" />
                                        <RowStyle  Height='20px' />
                                     </asp:GridView>
                                     <%=pager%>
                                </div>
		                    </td>
		                </tr>
		            </table>
		        </td>
		    </tr>
		</table>
    </div>
    </form>
</body>
</html>
